// intercept 村庄是否为plus帐号
TrvnInterceptorService.installInterceptor( {
	name : "village-plus.IsPlus",
	isAvailble : function() {
		return true;
	},
	intercept : function(doc) {
		var logoImg = doc.evaluateXPath('//div[@id="lleft"]//img[@class="logo"]');
		if (!logoImg || !logoImg[0]) return;
		TrvnCfg.getCurrentAccount().plus = logoImg[0].src.contains("travian1.gif");
	}
});
// intercept 村庄 plus
TrvnInterceptorService.installInterceptor( {
	name : "village-plus.VillagePlus",
	isAvailble : function() {
		return true;
	},
	intercept : function(doc) {
		var thisObject = this;
		var btn = doc.$C("a");
		btn.innerHTML = '&nbsp;&nbsp;&nbsp;&nbsp;<b>村庄 <font color="#71d000">P</font><font color="#ff6f0f">l</font><font color="#71d000">u</font><font color="#ff6f0f">s</font></b>';
		btn.href = 'javascript:;';
		var vlgTable = doc.evaluateXPath(TrvnCfg.queryXPath("villageTable"))[0];
		if (!vlgTable) {
			var rightDiv = doc.$C('div');
			rightDiv.id = 'lright1';
			rightDiv.appendChild(btn);
			doc.$G('lmidall').appendChild(rightDiv);
		} else {
			vlgTable.parentNode.insertBefore(btn, vlgTable);
		}
		btn.addEventListener('click', function() {
			try {
				var vlgDiv = doc.$G('VLG_PLUS_DIV');
				if (vlgDiv) {
					vlgDiv.style.display = 'block';
					return;
				}
				var vlgDiv = doc.$C("div");
				vlgDiv.id = 'VLG_PLUS_DIV';
				vlgDiv.style.position = 'absolute';
				vlgDiv.style.left = '154px';
				vlgDiv.style.top = '112px';
				vlgDiv.style.width = '500px';
				vlgDiv.style.zIndex = 80;
				vlgDiv.style.backgroundColor = '#FFFFFF';
				vlgDiv.style.border = '1px outset #C0C0C0';
				vlgDiv.style.paddingTop = '8px';
				vlgDiv.innerHTML = '<div id="VLG_DIV_BAR"><b>村庄 <font color="#71d000">P</font><font color="#ff6f0f">l</font><font color="#71d000">u</font><font color="#ff6f0f">s</font></b></div><p class="txt_menue">'
						+ '<a href="javascript:;">概况</a> | '
						+ '<a href="javascript:;">资源</a> | '
						+ '<a href="javascript:;">生产力</a> | '
						+ '<a href="javascript:;">仓库</a> | '
						+ '<a href="javascript:;">活动与研发</a></p>';
				doc.body.appendChild(vlgDiv);
				thisObject.interceptOverview(doc, vlgDiv);
				var bar = doc.$G('VLG_DIV_BAR');
				var closeBtn = doc.$C('a');
				closeBtn.innerHTML = '关闭';
				closeBtn.href = 'javascript:;';
				closeBtn.style.position = 'absolute';
				closeBtn.style.right = '0px';
				closeBtn.addEventListener('click', function() {
					vlgDiv.style.display = 'none';
				}, false);
				bar.appendChild(closeBtn);
				bar.style.cursor = 'move';
				bar.style.position = 'relative';
				bar.style.textAlign = 'center';
				var moveObj = {};
				bar.addEventListener('mousedown', function(event) {
					moveObj._mDown = true;
					moveObj._lastX = event.clientX;
					moveObj._lastY = event.clientY;
					return false;
				}, false);
				doc.addEventListener('mousemove', function(event) {
					if (!moveObj._mDown) return;
					var l = TrvnUtils.parseNumber(vlgDiv.style.left) + event.clientX - moveObj._lastX;
					var t = TrvnUtils.parseNumber(vlgDiv.style.top) + event.clientY - moveObj._lastY;
					vlgDiv.style.left = (l > 0 ? l : 0) + 'px';
					vlgDiv.style.top = (t > 0 ? t : 0) + 'px';
					moveObj._lastX = event.clientX;
					moveObj._lastY = event.clientY;
				}, false);
				doc.addEventListener('mouseup', function() {
					moveObj._mDown = false;
				}, false);

				var menus = doc.evaluateXPath('//div[@id="VLG_PLUS_DIV"]//p[@class="txt_menue"]//a');
				for (var i = 0;i < menus.length; i++) {
					if (i == 0) {
						menus[i].addEventListener('click', function() {
							try {
								thisObject.interceptOverview(doc, vlgDiv);
							} catch (e) {
								TrvnUtils.Logger.error("village-plus.js 400: " + e);
							}
						}, false);
					} else if (i == 1) {
						menus[i].addEventListener('click', function() {
							try {
								thisObject.interceptResource(doc, vlgDiv);
							} catch (e) {
								TrvnUtils.Logger.error("village-plus.js 401: " + e);
							}
						}, false);
					} else if (i == 2) {
						menus[i].addEventListener('click', function() {
							try {
								thisObject.interceptProductivity(doc, vlgDiv);
							} catch (e) {
								TrvnUtils.Logger.error("village-plus.js 402: " + e);
							}
						}, false);
					} else if (i == 3) {
						menus[i].addEventListener('click', function() {
							try {
								thisObject.interceptWarehouse(doc, vlgDiv);
							} catch (e) {
								TrvnUtils.Logger.error("village-plus.js 403: " + e);
							}
						}, false);
					} else if (i == 4) {
						menus[i].addEventListener('click', function() {
							try {
								thisObject.interceptActivityAndResearch(doc, vlgDiv);
							} catch (e) {
								TrvnUtils.Logger.error("village-plus.js 404: " + e);
							}
						}, false);
					}
				}
			} catch (e) {
				TrvnUtils.Logger.error('village-plus.VillagePlus 401: ' + e);
			}
		}, false);

		if (!doc.URL.contains("dorf3.php")) return;
		var params = doc.URL.toQueryParams();
		params.s = params.s ? params.s : 1;

		var table = doc.evaluateXPath('//div[@id="lmid2"]//table')[0];
		if (!table) return;
		var caption = table.createCaption();
		caption.className = "rbg";
		caption.innerHTML = table.rows[0].cells[0].innerHTML;
		table.deleteRow(0);
		var thead = table.createTHead();
		thead.className = "sort-header";
		thead.appendChild(table.rows[0]);
		if (params.s == 2 || params.s == 4 || params.s == 5) {
			table.createTFoot().appendChild(table.rows[table.rows.length - 1]);
			table.tBodies[0].deleteRow(table.tBodies[0].rows.length - 1);
		}
		new SortedTable(table, this.sortedTableBehaviors[params.s - 1]);

		if (params.s == 1 || params.s == 2) {
			var rows = table.tBodies[0].rows;
			for (var i = 0;i < rows.length; i++) {
				rows[i].cells[3 + parseInt(params.s)].firstChild.href = "build.php?gid=17&newdid="
						+ rows[i].cells[0].firstChild.href.toQueryParams().newdid;
			}
		}
	},
	_tableIds : {
		overview : "OVERVIEW_TABLE",
		resource : "RESOURCE_TABLE",
		warehouse : "WAREHOUSE_TABLE",
		cp : "CP_TABLE",
		productivity : "PRODUCTIVITY_TABLE"
	},
	toggleTable : function(doc, id) {
		for (var i in this._tableIds) {
			if (!doc.$G(this._tableIds[i])) continue;
			if (id == this._tableIds[i]) {
				doc.$G(this._tableIds[i]).style.display = "table";
			} else {
				doc.$G(this._tableIds[i]).style.display = "none";
			}
		}
	},
	interceptOverview : function(doc, div) {
		if (doc.$G(this._tableIds.overview)) {
			this.toggleTable(doc, this._tableIds.overview);
			return;
		}
		var table = doc.$C("table");
		table.id = this._tableIds.overview;
		table.className = "tbg";
		table.cellSpacing = 1;
		table.cellPadding = 2;
		table.appendChild(doc.$C("tbody"));
		var caption = table.createCaption();
		caption.innerHTML = "概况";
		caption.className = "rbg";
		var thead = table.createTHead();
		thead.innerHTML = '<tr><td width="150">村庄</td><td>建筑</td></tr>';
		var curVlg = TrvnCfg.getCurrentVillage();
		TrvnUtils.each(TrvnCfg.getCurrentAccount().villages, function(villageId, village) {
			var row = table.tBodies[0].insertRow(-1);
			var html = '<ul style="margin:0px;list-style:none;padding-left:7px;">';
			if (village.tasks) {
				TrvnUtils.each(village.tasks[TrvnTaskManager.BUILD_TYPE], function(taskId, task, k) {
					if (!task) return;
					html += '<li>' + task.titles[0] + '，'
							+ TrvnUtils.millisecondsToTime(task.finishTime - new Date().getTime()) + '</li>';
				});
			}
			html += '</ul>';
			var q = TrvnResourceManager.getCurrentQuantity(village);
			if (villageId == curVlg.villageId) {
				row.innerHTML = '<td class="s7 li ou"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="left ou">' + html + '</td>';
			} else {
				row.innerHTML = '<td class="s7"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="left">' + html + '</td>';
			}
		});
		div.appendChild(table);
		new SortedTable(table, this.sortedTableBehaviors[5]);
		this.toggleTable(doc, this._tableIds.overview);
	},
	interceptResource : function(doc, div) {
		if (doc.$G(this._tableIds.resource)) {
			this.toggleTable(doc, this._tableIds.resource);
			return;
		}
		var table = doc.$C("table");
		table.id = this._tableIds.resource;
		table.className = "tbg";
		table.cellSpacing = 1;
		table.cellPadding = 2;
		table.appendChild(doc.$C("tbody"));
		var caption = table.createCaption();
		caption.innerHTML = "资源";
		caption.className = "rbg";
		var thead = table.createTHead();
		thead.innerHTML = '<tr><td width="150">村庄</td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/1.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/2.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/3.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/4.gif') + '" /></td>' + '</tr>';
		var curVlg = TrvnCfg.getCurrentVillage();
		var qsum = {
			lumber : 0,
			clay : 0,
			iron : 0,
			crop : 0
		};
		TrvnUtils.each(TrvnCfg.getCurrentAccount().villages, function(villageId, village) {
			var row = table.tBodies[0].insertRow(-1);
			var q = TrvnResourceManager.getCurrentQuantity(village);
			qsum.lumber += q.lumber;
			qsum.clay += q.clay;
			qsum.iron += q.iron;
			qsum.crop += q.crop;
			if (villageId == curVlg.villageId) {
				row.innerHTML = '<td class="s7 li ou"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="r7 ou">' + q.lumber + '</td>' + '<td class="r7 ou">' + q.clay
						+ '</td>' + '<td class="r7 ou">' + q.iron + '</td>' + '<td class="r7 re ou">' + q.crop
						+ '</td>';
			} else {
				row.innerHTML = '<td class="s7"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="r7">' + q.lumber + '</td>' + '<td class="r7">' + q.clay + '</td>'
						+ '<td class="r7">' + q.iron + '</td>' + '<td class="r7">' + q.crop + '</td>';
			}
		});
		var tFoot = table.createTFoot();
		tFoot.innerHTML = '<tr><td class="s7">总计</td><td class="r7">' + qsum.lumber + '</td><td class="r7">'
				+ qsum.clay + '</td><td class="r7">' + qsum.iron + '</td><td class="r7">' + qsum.crop + '</td></tr>';
		div.appendChild(table);
		new SortedTable(table, this.sortedTableBehaviors[1]);
		this.toggleTable(doc, this._tableIds.resource);
	},
	interceptWarehouse : function(doc, div) {
		if (doc.$G(this._tableIds.warehouse)) {
			this.toggleTable(doc, this._tableIds.warehouse);
			return;
		}
		var table = doc.$C("table");
		table.id = this._tableIds.warehouse;
		table.className = "tbg";
		table.cellSpacing = 1;
		table.cellPadding = 2;
		table.appendChild(doc.$C("tbody"));
		var caption = table.createCaption();
		caption.innerHTML = "仓库";
		caption.className = "rbg";
		var thead = table.createTHead();
		thead.innerHTML = '<tr><td width="150">村庄</td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/1.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/2.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/3.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/a/clock.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/4.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/a/clock.gif') + '" /></td>' + '</tr>';
		var curVlg = TrvnCfg.getCurrentVillage();
		TrvnUtils.each(TrvnCfg.getCurrentAccount().villages, function(villageId, village) {
			var row = table.tBodies[0].insertRow(-1);
			var q = TrvnResourceManager.getCurrentQuantity(village);
			var p = village.capacity ? {
				lumber : parseInt(q.lumber * 100 / village.capacity.warehouse + 1) + "%",
				clay : parseInt(q.clay * 100 / village.capacity.warehouse + 1) + "%",
				iron : parseInt(q.iron * 100 / village.capacity.warehouse + 1) + "%",
				crop : parseInt(q.crop * 100 / village.capacity.granary + 1) + "%"
			} : {
				lumber : "-",
				clay : "-",
				iron : "-",
				crop : "-"
			};
			var t = village.capacity ? {
				lumber : q.lumber + '/' + village.capacity.warehouse,
				clay : q.clay + '/' + village.capacity.warehouse,
				iron : q.iron + '/' + village.capacity.warehouse,
				crop : q.crop + '/' + village.capacity.granary
			} : {
				lumber : q.lumber + '/-',
				clay : q.clay + '/-',
				iron : q.iron + '/-',
				crop : q.crop + '/-'
			};
			var f;
			if (village.productivity && village.capacity && q.lumber != '-') {
				f = {
					warehouse : Number.MAX_VALUE,
					granary : Number.MAX_VALUE
				};
				for (var type in village.productivity) {
					if (type == "crop") {
						var time;
						if (village.productivity[type] < 0) {
							time = 3600 * 1000 / village.productivity[type] * q[type];
						} else {
							time = 3600 * 1000 / village.productivity[type] * (village.capacity.granary - q[type]);
						}
						if (time < f.granary) {
							f.granary = time;
						}
					} else if (village.productivity[type] < 0) {
						f.warehouse = "|";
					} else {
						var time = 3600 * 1000 / village.productivity[type] * (village.capacity.warehouse - q[type]);
						if (time < f.warehouse) {
							f.warehouse = time;
						}
					}
				}
				f.granary = (f.granary > 0 ? '' : '-') + TrvnUtils.millisecondsToTime(Math.abs(f.granary));
				f.warehouse = TrvnUtils.millisecondsToTime(f.warehouse);
			} else {
				f = {
					warehouse : '-',
					granary : '-'
				};
			}
			if (villageId == curVlg.villageId) {
				row.innerHTML = '<td class="s7 li ou"><a href="dorf2.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="ou" title="' + t.lumber + '">' + p.lumber + '</td>'
						+ '<td class="ou" title="' + t.clay + '">' + p.clay + '</td>' + '<td class="ou" title="'
						+ t.iron + '">' + p.iron + '</td>' + '<td class="ou">' + f.warehouse + '</td>'
						+ '<td class="ou" title="' + t.crop + '">' + p.crop + '</td>' + '<td class="re ou">'
						+ f.granary + '</td>';
			} else {
				row.innerHTML = '<td class="s7"><a href="dorf2.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td title="' + t.lumber + '">' + p.lumber + '</td>' + '<td title="' + t.clay
						+ '">' + p.clay + '</td>' + '<td title="' + t.iron + '">' + p.iron + '</td>' + '<td>'
						+ f.warehouse + '</td>' + '<td title="' + t.crop + '">' + p.crop + '</td>' + '<td>' + f.granary
						+ '</td>';
			}
		});
		div.appendChild(table);
		new SortedTable(table, this.sortedTableBehaviors[2]);
		this.toggleTable(doc, this._tableIds.warehouse);
	},
	interceptActivityAndResearch : function(doc, div) {
		if (doc.$G(this._tableIds.cp)) {
			this.toggleTable(doc, this._tableIds.cp);
			return;
		}
		var table = doc.$C("table");
		table.id = this._tableIds.cp;
		table.className = "tbg";
		table.cellSpacing = 1;
		table.cellPadding = 2;
		table.appendChild(doc.$C("tbody"));
		var caption = table.createCaption();
		caption.innerHTML = "活动与研发";
		caption.className = "rbg";
		var thead = table.createTHead();
		thead.innerHTML = '<tr><td width="150">村庄</td>' + '<td>市政厅</td>' + '<td>研发所</td>' + '<td>铁匠铺</td>'
				+ '<td>军械库</td>' + '</tr>';
		var curVlg = TrvnCfg.getCurrentVillage();
		TrvnUtils.each(TrvnCfg.getCurrentAccount().villages, function(villageId, village) {
			var row = table.tBodies[0].insertRow(-1);
			function calTime(type, tid, gid) {
				var t = '<a href="build.php?gid=' + gid + '&newdid=' + villageId
						+ '"><span class="c"><b> &#8226; </b></span></a>';
				if (!village.tasks) return t;
				var tasks = village.tasks[type];
				if (tasks && tasks[tid]) {
					t = tasks[tid].finishTime - new Date().getTime();
					t = '<span title="' + tasks[tid].titles[0] + '">' + TrvnUtils.millisecondsToTime(t) + '</span>';
				}
				return t;
			}
			var t1 = calTime(TrvnTaskManager.ACTIVITY_TYPE, "activity", 24);
			var t2 = calTime(TrvnTaskManager.RESEARCH_DEV_TYPE, "academy", 22);
			var t3 = calTime(TrvnTaskManager.RESEARCH_ATTACK_TYPE, "blacksmith", 12);
			var t4 = calTime(TrvnTaskManager.RESEARCH_ARMOUR_TYPE, "armoury", 13);
			if (villageId == curVlg.villageId) {
				row.innerHTML = '<td class="s7 li ou"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="ou">' + t1 + '</td>' + '<td class="ou">' + t2 + '</td>'
						+ '<td class="ou">' + t3 + '</td>' + '<td class="re ou">' + t4 + '</td>';
			} else {
				row.innerHTML = '<td class="s7"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td>' + t1 + '</td>' + '<td>' + t2 + '</td>' + '<td>' + t3 + '</td>' + '<td>'
						+ t4 + '</td>';
			}
		});
		div.appendChild(table);
		new SortedTable(table, this.sortedTableBehaviors[3]);
		this.toggleTable(doc, this._tableIds.cp);
	},
	interceptProductivity : function(doc, div) {
		if (doc.$G(this._tableIds.productivity)) {
			this.toggleTable(doc, this._tableIds.productivity);
			return;
		}
		var table = doc.$C("table");
		table.id = this._tableIds.productivity;
		table.className = "tbg";
		table.cellSpacing = 1;
		table.cellPadding = 2;
		table.appendChild(doc.$C("tbody"));
		var caption = table.createCaption();
		caption.innerHTML = "生产力";
		caption.className = "rbg";
		var thead = table.createTHead();
		thead.innerHTML = '<tr><td width="150">村庄</td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/1.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/2.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/3.gif') + '" /></td>' + '<td><img class="res" src="'
				+ TrvnCfg.queryUrl('img/un/r/4.gif') + '" /></td>' + '</tr>';
		var curVlg = TrvnCfg.getCurrentVillage();
		var psum = {
			lumber : 0,
			clay : 0,
			iron : 0,
			crop : 0
		};
		TrvnUtils.each(TrvnCfg.getCurrentAccount().villages, function(villageId, village) {
			var row = table.tBodies[0].insertRow(-1);
			psum.lumber += village.productivity.lumber;
			psum.clay += village.productivity.clay;
			psum.iron += village.productivity.iron;
			psum.crop += village.productivity.crop;
			if (villageId == curVlg.villageId) {
				row.innerHTML = '<td class="s7 li ou"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="ou r7">' + village.productivity.lumber + '</td>'
						+ '<td class="ou r7">' + village.productivity.clay + '</td>' + '<td class="ou r7">'
						+ village.productivity.iron + '</td>' + '<td class="re ou r7">' + village.productivity.crop
						+ '</td>';
			} else {
				row.innerHTML = '<td class="s7"><a href="dorf1.php?newdid=' + villageId + '">' + village.title
						+ '</a></td>' + '<td class="r7">' + village.productivity.lumber + '</td>' + '<td class="r7">'
						+ village.productivity.clay + '</td>' + '<td class="r7">' + village.productivity.iron + '</td>'
						+ '<td class="r7">' + village.productivity.crop + '</td>';
			}
		});
		var tFoot = table.createTFoot();
		tFoot.innerHTML = '<tr><td class="s7">总计</td><td class="r7">' + psum.lumber + '</td><td class="r7">'
				+ psum.clay + '</td><td class="r7">' + psum.iron + '</td><td class="r7">' + psum.crop + '</td></tr>';
		div.appendChild(table);
		new SortedTable(table, this.sortedTableBehaviors[1]);
		this.toggleTable(doc, this._tableIds.productivity);
	},
	sortedTableBehaviors : [ {
		getSortableValueAt : function(rowObj, cellObj) {
			var v = cellObj.innerHTML.stripTags();
			switch (cellObj.cellIndex) {
				case 0 :
					return v;
				case 1 :
				case 2 :
				case 3 :
					if (v.blank()) {
						return cellObj.childNodes.length;
					}
					return 0;
				case 4 :
					return TrvnUtils.parseNumber(v.substring(0, v.indexOf("/") + 1));
			}
			return "";
		}
	}, {
		getSortableValueAt : function(rowObj, cellObj) {
			var v = cellObj.innerHTML.stripTags();
			switch (cellObj.cellIndex) {
				case 0 :
					return v;
				case 1 :
				case 2 :
				case 3 :
				case 4 :
					return TrvnUtils.parseNumber(v);
				case 5 :
					return TrvnUtils.parseNumber(v.substring(0, v.indexOf("/") + 1));
			}
			return "";
		}
	}, {
		getSortableValueAt : function(rowObj, cellObj) {
			var v = cellObj.innerHTML.stripTags();
			switch (cellObj.cellIndex) {
				case 0 :
					return v;
				case 1 :
				case 2 :
				case 3 :
				case 5 :
					return TrvnUtils.parseNumber(v);
				case 4 :
				case 6 :
					return -TrvnUtils.timeToMilliseconds(v);
			}
			return "";
		}
	}, {
		getSortableValueAt : function(rowObj, cellObj) {
			var v = cellObj.innerHTML.stripTags();
			if (!TrvnCfg.getCurrentAccount().plus) {
				if (cellObj.cellIndex == 0) return v;
				else return TrvnUtils.timeToMilliseconds(v);
			}
			switch (cellObj.cellIndex) {
				case 0 :
					return v;
				case 1 :
					return TrvnUtils.parseNumber(v);
				case 2 :
					if (v.contains("•")) {
						return 0;
					}
					if (v.contains("-")) {
						return -1;
					}
					return TrvnUtils.timeToMilliseconds(v);
				case 3 :
					if (v.blank()) {
						return cellObj.childNodes.length;
					}
					return 0;
				case 4 :
					return TrvnUtils.parseNumber(v.substring(0, v.indexOf("/") + 1));
			}
			return "";
		}
	}, {
		getSortableValueAt : function(rowObj, cellObj) {
			var v = cellObj.innerHTML.stripTags();
			switch (cellObj.cellIndex) {
				case 0 :
					return v;
				default :
					return TrvnUtils.parseNumber(v);
			}
		}
	}, {
		getSortableValueAt : function(rowObj, cellObj) {
			var v = cellObj.innerHTML.stripTags();
			switch (cellObj.cellIndex) {
				case 0 :
					return v;
				default :
					if (v.blank) return 0;
					return cellObj.firstChild.childNodes.length;
			}
		}
	}]
});